package com.htfyun.roobofactory;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.htfyun.roobofactory.config.PCCommand;
import com.htfyun.roobofactory.config.RooboBuildConfig;
import com.htfyun.roobofactory.factorytest.FactoryTestItemsEnum;
import com.htfyun.roobofactory.htfyunUtils.NvDataTool;
import com.htfyun.roobofactory.utils.FileReadWrite;
import com.roobo.common.utils.Utils;
import com.roobo.hardware.RockChipSn;


/**
 * Created by sst on 2018/7/17.
 */

public class PCCommandReceiver extends BroadcastReceiver {

    public final static String TAG = "PCCommandReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        final String action = intent.getAction();

        if (action == null) {
            return;
        }

        Log.e(TAG, "action = " + action);

        if (action.equals(PCCommand.PC_ACTION_SET_FT_IGNORE_BSN_BURNT)) {

            boolean ignore = intent.getBooleanExtra(PCCommand.ACTION_SET_FT_IGNORE_BSN_BURNT_EXTRAL_BOOLEAN_KEY, false);
            Log.e(TAG, "ignore = " + ignore);
            RooboBuildConfig.set_FT_IGNORE_BSN_BURNT(ignore);

        } else if (action.equals(PCCommand.PC_ACTION_SET_FT_FORCE_ALL_TEST_ITEMS_PASS)) {

            boolean passed = intent.getBooleanExtra(PCCommand.ACTION_SET_FT_FORCE_ALL_TEST_ITEMS_PASS_EXTRAL_BOOLEAN_KEY, false);
            Log.e(TAG, "passed = " + passed);
            RooboBuildConfig.set_FT_FORCE_ALL_TEST_ITEMS_PASSED(passed);

        } else {

            startPCCommandHandleActivity(context, action);

        }

    }

    private void startPCCommandHandleActivity(Context context, String action) {

        Intent intent = new Intent(context, PCCommandHandleActivity.class);
        intent.setAction(action);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

    }
}
